home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_LimitRows_JScript.asp < prev    next >
Encoding:
Text File  |  1999-07-21  |  1.7 KB  |  97 lines

  1. <%@ LANGUAGE = JScript  %>
  2.  
  3. <!--METADATA TYPE="typelib" 
  4. uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
  5.  
  6. <HTML>
  7.     <HEAD>
  8.         <TITLE>LimitRows From Database</TITLE>
  9.     </HEAD>
  10.  
  11.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  12.  
  13.  
  14.         <!-- Display Header -->
  15.  
  16.         <font size="4" face="Arial, Helvetica">
  17.         <b>LimitRows From Database</b></font><br>
  18.     
  19.         <hr size="1" color="#000000">
  20.  
  21.         Contacts within the Authors Database:<br><br>
  22.  
  23.         <%
  24.             var oConn;    
  25.             var oRs;    
  26.             var curDir;    
  27.             var Index;    
  28.  
  29.             
  30.             // Map authors database to physical path
  31.             
  32.             curDir = Server.MapPath("authors.mdb");
  33.  
  34.  
  35.             // Create ADO Connection Component to connect
  36.             // with sample database
  37.             
  38.  
  39.             
  40.             
  41.             oConn = Server.CreateObject("ADODB.Connection");
  42.             oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +curDir);
  43.         
  44.         
  45.             // Create ADO Recordset Component
  46.             
  47.             oRs = Server.CreateObject("ADODB.Recordset");
  48.             oRs.ActiveConnection = oConn;
  49.             
  50.             
  51.             // Set Recordset PageSize so that it only holds 10 rows
  52.             
  53.             oRs.PageSize = 10;
  54.             
  55.             
  56.             // Get recordset
  57.             
  58.             oRs.Source = "SELECT * FROM authors";
  59.             oRs.CursorType = adOpenStatic;
  60.             
  61.             
  62.             // Open Recordset
  63.             
  64.             oRs.Open();
  65.         %>
  66.  
  67.  
  68.         <TABLE border = 1>
  69.         <%  
  70.             var RecordCount;
  71.             RecordCount = 0;
  72.         
  73.             while ((!oRs.eof) && (RecordCount < oRs.PageSize)) { %>
  74.  
  75.                 <tr>
  76.                     <% for(Index=0; Index < oRs.fields.count; Index++) { %>
  77.                         <TD VAlign=top><% = oRs(Index)%></TD>
  78.                     <% } %>
  79.                 </tr>
  80.             
  81.                 <%
  82.                     RecordCount = RecordCount + 1;
  83.                     oRs.MoveNext(); 
  84.             } 
  85.         %>
  86.  
  87.         </TABLE>
  88.  
  89.  
  90.         <%   
  91.             oRs.Close();
  92.             oConn.Close();
  93.         %>
  94.  
  95.     </BODY>
  96. </HTML>
  97.